/******************************************************************************************
 * Import
 ******************************************************************************************/

// module
import Taro, { Component } from '@tarojs/taro'

// project
import { CPage, CContent, CHeader, CFooter, CFloat, CAround, CBetween, CCenter, CRow, CWrap, CLine, CHand, CItemX, CItemY, CText, CLabel, CSvg, CImage, CButton } from '../../../library/comp';
import { Base64, Gen, Time, Zip, Session, Storage, Http } from '../../../library/func';
import Icon from '../../../project/style/icon';
import DoHttp from '../../../project/func/http/http';
import { ScrollView } from '@tarojs/components';
/******************************************************************************************
 * Export Class
 ******************************************************************************************/

export default class Index extends Component {

	/*------------------------------------------------------------------------------------
	 * 初始化
	 *-----------------------------------------------------------------------------------*/
	constructor(props) {
		super(props);

		/**
		 * state
		 */
		this.state = {
			userInfo:{},
			// 获取屏幕高度
			scrollHeight: wx.getSystemInfoSync().windowHeight,
		}
	}

	/*------------------------------------------------------------------------------------
	 * 生命周期
	 *-----------------------------------------------------------------------------------*/
	// didMount
	componentDidMount() {
		Storage.get({
			key: 'userInfo',
			success:(res)=>{
				console.log(res);
				this.setState({
					userInfo:res,
				})
			}
		});

	}
	
	/*------------------------------------------------------------------------------------
	 * 事件处理
	 *-----------------------------------------------------------------------------------*/
	// onClick
	onClick = (e)=> {
		
	}
    
    // onRedirect
    onRedirect = (url, e)=> {
        wx.redirectTo({
            url: url
        })
    }

    // onNavigate
    // onNavigate
    onNavigate = (url, e)=> {
		wx.navigateTo({
			url: url
		})
	}

	/*------------------------------------------------------------------------------------
	 * 自定义方法
	 *-----------------------------------------------------------------------------------*/
	config = {
        navigationBarTitleText: 'vip首页',
        navigationBarBackgroundColor: '#1F1F1F',
		navigationBarTextStyle: '#fff',
	}

	/*------------------------------------------------------------------------------------
	 * 渲染
	 *-----------------------------------------------------------------------------------*/
	render () {
		// 屏幕高度
		const style = {height: this.state.scrollHeight +'px',background:'#fff'}
		return (
			<CPage>
				<ScrollView style={style}>

					{/* 顶部 */}
					<CRow bg='#1F1F1F' h='400' y="top">
						<CRow h="200" mt="60" y="center">
							<image style="width:150rpx; height:150rpx; border-radius: 150rpx; border:4rpx solid #E2BE70; margin-left:50rpx;" src={ this.state.userInfo.avatarUrl }></image>
							<CHand size='34' color='#fff' ml='30'>{ this.state.userInfo.nickName }</CHand>
						</CRow>	
					</CRow>

					{/* vip特权介绍 */}
					<CRow bg="white" x="center"  mt="-80" rt="40">
						{/* 图片 */}
						<image style="width:96%; height:540rpx; margin-top:60rpx;" src="http://image.mod.hesq.com.cn/rushbuy/assets/20181113/nvipcimg.png"/>
					</CRow>

                    {/* 提交区域 */}
                    <CItemY x="center" y="center">
						<CButton color="#fff" y="center" style="font-size:32rpx;" bg="#E7B962" h="80" px="40" ra="60"
						onClick={this.onNavigate.bind(this, '/screen/vip/normal/gift')}
						>补充资料赚积分升级VIP</CButton>
                    </CItemY>

				</ScrollView>

			</CPage>
		)
	}
}


